Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documents before running tests #165

Merged
merged 6 commits into from
May 23, 2021

Conversation

Blond11516
Copy link
Contributor

Updates the run test command to save the current document if necessary, as reported in elixir-lsp/elixir-ls#438.

I haven't found a way to save the document from elixir-ls itself, so it looks like every extension is going to have to re-implement this functionality. Maybe this should be documented somewhere?

@Blond11516 Blond11516 changed the title Fix documents before running tests Draft: Fix documents before running tests Jan 30, 2021
@Blond11516 Blond11516 changed the title Draft: Fix documents before running tests Fix documents before running tests Jan 30, 2021
@Blond11516 Blond11516 marked this pull request as draft January 30, 2021 20:18
@Blond11516
Copy link
Contributor Author

I just realized that saving the document may lead to a failure to run the tests if the name of a describe or test is changed. I'll close this while I work on a better solution.

@Blond11516 Blond11516 closed this Jan 30, 2021
@Blond11516
Copy link
Contributor Author

Reopening this because handling renamed tests ended up being quite a bit more complicated than I had hoped.

From what I could find, most other extensions that implement similar test running through code lenses in VSCode do it through the CodeLensProvider, which appears to be called on code change (meaning the lenses are effectively always up to date), whereas the LSP command appears to only be called on document save. Obviously, this behaviour may differ between editors.

One avenue to handle this is to re-request code lenses when we detect that the file is dirty, but then the problem becomes matching those new lenses with the current state of the document. Considering that tests can be renamed, moved around, moved between describes, etc., this feels very hard to do accurately, if possible at all.

Another option is the Code Lens Refresh Request defined by LSP. This would have to be implemented in elixir_ls and would allow us to refresh code lenses in-between saves, but refreshing on change feels like a bad idea given the time it currently takes to generate lenses. There's always the option of implementing some kind of debouncing, but the cost/value ratio is starting to drop dramatically imo.

@Blond11516 Blond11516 reopened this Feb 14, 2021
@Blond11516 Blond11516 marked this pull request as ready for review February 14, 2021 21:47
@Blond11516
Copy link
Contributor Author

@axelson Sorry for tagging you out of nowhere but I wasn't sure anyone would look at this since it's been stagnant for a month and a half.

The TL;DR of my last comment is that I think this is the best we can do without investing significant effort into this issue, which I don't think is worth it...

So I've pulled master and I think this is ready to be merged 🙂

Copy link
Member

@axelson axelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this ❤️ and sorry for the delay.

@axelson axelson merged commit 5c66dd7 into elixir-lsp:master May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants